﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UcEditCompany.ascx.cs" Inherits="CompanyManagement.usercontrol.UcEditCompany" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%--<div class="alert alert-block alert-success" id="success" runat="server" visible="false">
    <asp:Literal ID="ltrSuccess" runat="server"></asp:Literal>
</div>
<div class="alert alert-block alert-error" id="error" runat="server" visible="false">
    <asp:Literal ID="ltrError" runat="server"></asp:Literal>
</div>--%>
<asp:Label ID="ltrMessage" runat="server"></asp:Label>
<table class="table">
    <%--<tr>
        <td colspan="2">
            <h4 id="H1" class="lighter" runat="server" visible='<%# (DataItem is Telerik.Web.UI.GridInsertionObject) %>'>
                <i class="icon-add"></i>
                Thêm mới Doanh nghiệp
            </h4>
            <h4 id="H2" class="lighter" runat="server" visible='<%# !(DataItem is Telerik.Web.UI.GridInsertionObject) %>'>
                <i class="icon-pencil"></i>
                Sửa thông tin Doanh nghiệp: <%# DataBinder.Eval( Container, "DataItem.ID") == null ? -1: DataBinder.Eval( Container, "DataItem.ID") %>
            </h4>
        </td>
    </tr>--%>
    <tr>
        <td style="min-width: 300px; max-width: 450px !important">
            <dl class="dl-horizontal">
                <dt>Tên công ty</dt>
                <dd>
                    <asp:TextBox ID="txtName" Rows="2" TextMode="MultiLine" runat="server" Text='<%# ProcessMyDataItem(DataBinder.Eval( Container, "DataItem.Name")) %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" CssClass="help-block" ErrorMessage="Vui lòng nhập tên công ty." ControlToValidate="txtName" Display="Dynamic" ForeColor="Red"></asp:RequiredFieldValidator>
                </dd>
                <dt>Tên Giao dịch</dt>
                <dd>
                    <asp:TextBox ID="txtTradingName" Rows="2" TextMode="MultiLine" runat="server" Text='<%# ProcessMyDataItem(DataBinder.Eval( Container, "DataItem.TradingName")) %>'></asp:TextBox>
                </dd>
                <dt>Tên viết tắt</dt>
                <dd>
                    <asp:TextBox ID="txtAbbreviation" Rows="2" TextMode="MultiLine" runat="server" Text='<%# ProcessMyDataItem(DataBinder.Eval( Container, "DataItem.Abbreviation")) %>'></asp:TextBox>
                </dd>
                <dt>Tên giám đốc</dt>
                <dd>
                    <asp:TextBox ID="txtDirectorName" runat="server" Text='<%# ProcessMyDataItem(DataBinder.Eval( Container, "DataItem.DirectorName")) %>'></asp:TextBox>
                </dd>
                <dt>Chủ sở hữu</dt>
                <dd>
                    <asp:TextBox ID="txtOwner" runat="server" Text='<%# ProcessMyDataItem(DataBinder.Eval( Container, "DataItem.Owner")) %>'></asp:TextBox>
                </dd>
                <dt>Số ĐT</dt>
                <dd>
                    <asp:TextBox ID="txtPhone" runat="server" Text='<%# ProcessMyDataItem( DataBinder.Eval( Container, "DataItem.Phone")) %>'></asp:TextBox>
                </dd>
                <dt>Địa chỉ</dt>
                <dd>
                    <asp:TextBox ID="txtAddress" runat="server" Text='<%# ProcessMyDataItem(DataBinder.Eval( Container, "DataItem.Address")) %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtAddress" CssClass="help-block" Display="Dynamic" ErrorMessage="Vui lòng nhập địa chỉ công ty." ForeColor="Red"></asp:RequiredFieldValidator>
                </dd>
                <dt>Quận/Huyện</dt>
                <dd>
                    <asp:TextBox ID="txtDistrictCode" runat="server" Text='<%# ProcessMyDataItem(DataBinder.Eval( Container, "DataItem.DistrictCode")) %>'></asp:TextBox>
                    <%--<asp:DropDownList ID="ddlDistrict" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlDistrict_SelectedIndexChanged"></asp:DropDownList>--%>
                </dd>
                <dt>Phường/Xã</dt>
                <dd>
                    <asp:TextBox ID="txtWardCode" runat="server" Text='<%# ProcessMyDataItem(DataBinder.Eval( Container, "DataItem.WardCode")) %>'></asp:TextBox>
                    <%--<asp:DropDownList ID="ddlWard" runat="server"></asp:DropDownList>--%>
                </dd>
                <dt>Ngày thành lập</dt>
                <dd>
                    <%--<asp:TextBox ID="txtCompanyDateCreated" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.CompanyCreateDated") ?? "" %>'></asp:TextBox>--%>
                    <telerik:RadDatePicker ID="RadDateCompanyCreated" DateInput-DateFormat="dd/MM/yyyy" runat="server">
                    </telerik:RadDatePicker>
                </dd>
            </dl>
        </td>
        <td style="min-width: 300px; max-width: 450px !important">
            <dl class="dl-horizontal">

                <dt>CompanyNo(ĐKKD)</dt>
                <dd>
                    <asp:TextBox ID="txtCompanyNo" runat="server" Text='<%# ProcessMyDataItem(DataBinder.Eval( Container, "DataItem.CompanyNo")) %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" CssClass="help-block" ErrorMessage="Vui lòng nhập số ĐKKD." ControlToValidate="txtCompanyNo" Display="Dynamic" ForeColor="Red"></asp:RequiredFieldValidator>
                </dd>

                <dt>Số ĐKKD</dt>
                <dd>
                    <asp:TextBox ID="txtBusinessReg" runat="server" Text='<%# ProcessMyDataItem(DataBinder.Eval( Container, "DataItem.BusinessReg")) %>'></asp:TextBox>

                </dd>

                <dt>Số Vốn</dt>
                <dd>
                    <asp:TextBox ID="txtCapital" runat="server" Text='<%# ProcessMyDataItem(DataBinder.Eval( Container, "DataItem.Capital")) %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" CssClass="help-block" ErrorMessage="Vui lòng nhập số Vốn." ControlToValidate="txtCapital" Display="Dynamic" ForeColor="Red"></asp:RequiredFieldValidator>
                </dd>

                <dt>MSN 1</dt>
                <dd>
                    <asp:TextBox ID="txtMSN1" runat="server" Text='<%# ProcessMyDataItem(DataBinder.Eval( Container, "DataItem.MSN1")) %>'></asp:TextBox>
                </dd>

                <dt>MSN 2</dt>
                <dd>
                    <asp:TextBox ID="txtMSN2" runat="server" Text='<%# ProcessMyDataItem(DataBinder.Eval( Container, "DataItem.MSN2")) %>'></asp:TextBox>
                </dd>

                <dt>MSN 3</dt>
                <dd>
                    <asp:TextBox ID="txtMSN3" runat="server" Text='<%# ProcessMyDataItem(DataBinder.Eval( Container, "DataItem.MSN3")) %>'></asp:TextBox>
                </dd>

                <dt>MSN 4</dt>
                <dd>
                    <asp:TextBox ID="txtMSN4" runat="server" Text='<%# ProcessMyDataItem(DataBinder.Eval( Container, "DataItem.MSN4")) %>'></asp:TextBox>
                </dd>

                <dt style="padding-bottom: 5px">Loại công ty</dt>
                <dd style="padding-bottom: 5px">
                    <asp:DropDownList ID="ddlCompanyType" runat="server"></asp:DropDownList>
                </dd>
                <dt style="padding-bottom: 5px" runat="server" visible='<%# !(DataItem is Telerik.Web.UI.GridInsertionObject) %>'>Tình trạng</dt>
                <dd style="padding-bottom: 5px" runat="server" visible='<%# !(DataItem is Telerik.Web.UI.GridInsertionObject) %>'>
                    <asp:DropDownList ID="ddlStatus" runat="server">
                        <asp:ListItem Text="Đang hoạt động" Value="1"></asp:ListItem>
                        <asp:ListItem Text="Giải thể" Value="2"></asp:ListItem>
                        <asp:ListItem Text="Chuyển lĩnh vực" Value="3"></asp:ListItem>
                    </asp:DropDownList></dd>
                <dt style="padding-bottom: 5px" runat="server" visible='<%# !(DataItem is Telerik.Web.UI.GridInsertionObject) %>'>Ngày giải thể</dt>
                <dd style="padding-bottom: 5px" runat="server" visible='<%# !(DataItem is Telerik.Web.UI.GridInsertionObject) %>'>
                    <asp:DropDownList ID="ddlMonth" runat="server" Width="80px">
                        <asp:ListItem Text="Tháng" Value="-1"></asp:ListItem>
                        <asp:ListItem Text="1" Value="1"></asp:ListItem>
                        <asp:ListItem Text="2" Value="2"></asp:ListItem>
                        <asp:ListItem Text="3" Value="3"></asp:ListItem>
                        <asp:ListItem Text="4" Value="4"></asp:ListItem>
                        <asp:ListItem Text="5" Value="5"></asp:ListItem>
                        <asp:ListItem Text="6" Value="6"></asp:ListItem>
                        <asp:ListItem Text="7" Value="7"></asp:ListItem>
                        <asp:ListItem Text="8" Value="8"></asp:ListItem>
                        <asp:ListItem Text="9" Value="9"></asp:ListItem>
                        <asp:ListItem Text="10" Value="10"></asp:ListItem>
                        <asp:ListItem Text="11" Value="11"></asp:ListItem>
                        <asp:ListItem Text="12" Value="12"></asp:ListItem>
                    </asp:DropDownList>
                    &nbsp;-&nbsp;
                    <asp:DropDownList ID="ddlYear" runat="server" Width="80px"></asp:DropDownList>
                </dd>

                <dt runat="server" visible='<%# !(DataItem is Telerik.Web.UI.GridInsertionObject) %>'>Lý do giải thể</dt>
                <dd runat="server" visible='<%# !(DataItem is Telerik.Web.UI.GridInsertionObject) %>'>
                    <asp:TextBox ID="txtReasonDissolved" Rows="2" TextMode="MultiLine" runat="server" Text='<%# ProcessMyDataItem(DataBinder.Eval( Container, "DataItem.ReasionDissolved")) %>'></asp:TextBox>
                </dd>
            </dl>
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <dl class="dl-horizontal">
                <dt></dt>
                <dd>
                    <asp:Button ID="btnUpdate" Text="Lưu thay đổi" runat="server" CommandName="Update" Visible='<%# !(DataItem is Telerik.Web.UI.GridInsertionObject) %>'></asp:Button>
                    <asp:Button ID="btnInsert" Text="Thêm mới" runat="server" CommandName="PerformInsert"
                        Visible='<%# DataItem is Telerik.Web.UI.GridInsertionObject %>'></asp:Button>
                    &nbsp;
            <asp:Button ID="btnCancel" Text="Hủy" runat="server" CausesValidation="False"
                CommandName="Cancel"></asp:Button>
                </dd>
            </dl>
        </td>
    </tr>
</table>
<%--<script src="../Scripts/accounting.js"></script>--%>
<script type="text/javascript">
    $(function () {
        //$("[id*='txtCapital']").keyup(function () {
        //    amountF = $(this).val();
        //    amountF = accounting.formatNumber(amountF);
        //    $(this).val(amountF);
        //    //            alert(amountF);
        //});
        SearchText();
        function SearchText() {
            $("[id*='txtOwner']").autocomplete({
                source: function (request, response) {
                    $.ajax({
                        type: "POST",
                        contentType: "application/json; charset=utf-8",
                        url: "/Services/CompanyServices/GetCompany",
                        data: "{'txt':'" + $("[id*='txtOwner']").val() + "'}",
                        dataType: "json",
                        //async: false,
                        dataFilter: function (data) { return data; },
                        success: function (data) {
                            response($.map(data.d, function (item) {
                                return {
                                    label: item,
                                    value: item
                                }
                            }))
                        },
                        error: function (result) {
                            alert("Error");
                        }
                    });
                },
                minLength: 1,
                delay: 1000
            });
        }
    });
    </script>